package com.baymax.study.kafka.customize;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author baymax
 * @since 2025-05-18
 */
public class QueueTest {
    public static void main(String[] args) {
        Queue<String> queue = new LinkedList<>();
        queue.add("A");
        queue.add("B");
        queue.offer("C");
        queue.offer("D");
        queue.offer("E");

        print(queue);
        System.out.println("-------------");

        String poll = queue.poll(); // 移除并返回队列头部的元素
        String remove = queue.remove(); // 移除并返回队列头部的元素
        System.out.println("poll: " + poll);
        System.out.println("remove: " + remove);


        String peek = queue.peek(); // 返回队列的头部元素，但不移除
        String element = queue.element(); // 返回队列的头部元素，但不移除
        System.out.println("peek: " + peek);
        System.out.println("element: " + element);

        System.out.println("-------------");
        print(queue);
    }

    private static void print(Queue<String> queue) {
        for (String ele : queue) {
            System.out.println(ele);
        }
    }
}
